﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 天离终端防火墙_专业版.Tl_Warning
{
    /// <summary>
    /// 入侵警告窗体
    /// </summary>
    public partial class Invade_Warnig_Info : Form
    {
        private Timer timer;
        /// <summary>
        /// 定时器
        /// </summary>
        private int elapsedTime;
        /// <summary>
        /// 播放警告
        /// </summary>
        private SoundPlayer soundPlayer;
        public Invade_Warnig_Info()
        {
            InitializeComponent();
        }

        private void Invade_Warnig_Info_Load(object sender, EventArgs e)
        {

            timer = new Timer();
            timer.Interval = 500; // 设置闪烁间隔，单位为毫秒
            timer.Tick += timer1_Tick;

            soundPlayer = new SoundPlayer();
            soundPlayer.SoundLocation = "TL_Files/jinggao.wav"; // 设置音乐文件的路径
            soundPlayer.Play();

            // 启动定时器
            timer.Start();

            // 初始化计时器变量
            elapsedTime = 0;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Visible = !label1.Visible;
            // 增加计时器变量的值，单位为闪烁间隔
            elapsedTime += timer.Interval;

            // 判断是否达到5秒
            if (elapsedTime >= 10000)
            {
                // 停止定时器
                timer.Stop();

                // 关闭当前窗体
                this.Close();
            }
        }
    }
}
